<?php
require_once "../config.php";
require_once SESSION_INCLUDE;
require_once DB;

session_start();

function print_admin($user)
{
	if($user->isAdmin())
		return "Amministratore";
	else return "Utente";
}

	$db = get_session_db($db_config);
	
	if(!user_is_logged($db))
	{
		header("Location:http://".LOGIN_FILE);
		exit();
	}
	
	$user = get_session_user();
?>
<form id='gallery_user' method='post' action='../scripts/update_user.php'>
	<p style="text-align: center">Utente <i><?php echo $user->getUsername(); ?></i> loggato come <i><?php echo print_admin($user);?></php></i></p>

	<div class="left">Nome utente:</div><div class="right"><input type='text' id='user_username' name='user_username' value="<?php echo $user->get('user_username'); ?>"/></div>
	
	<div class="left">Vecchia password:</div><div class="right"><input type='password' id='user_password' name='user_password' /></div>
	
	<div class="left">Nuova password:</div><div class="right"><input type='password' id='new_password' name='new_password' /></div>
	
	<div class="left">Conferma password:</div><div class="right"><input type='password' id='confirm_password' name='confirm_password' /></div>

	<div class="left">Email:</div><div class="right"><input type='text' id='user_email' name='user_email' value="<?php echo $user->get('user_email'); ?>"/></div>

	<div class="left">Msn:</div><div class="right"><input type='text'	id='user_msnm' name='user_msnm' value="<?php echo $user->get('user_msnm'); ?>"/></div>

	<div class="left">Indirizzo:</div><div class="right"><textarea id='user_address' name='user_address'><?php echo $user->get('user_address'); ?></textarea></div>

	<div class="left">Telefono:</div><div class="right"><input id='user_phone' name='user_phone' value="<?php echo $user->get('user_phone'); ?>" /></div>

	<div class="left">Biografia:</div><div class="right"><textarea id='user_description' name='user_description'><?php echo $user->get('user_description'); ?></textarea></div>

	<div class="left" style="height: 100px"></div><div class="right"><input type='submit' /></div>
</form>
